/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.foxline.clinicplus.service;

import br.com.foxline.clinicplus.entity.Doctor;
import br.com.foxline.clinicplus.entity.Unattended;
import java.util.ArrayList;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.Query;

/**
 *
 * @author ely
 */
@Stateless
public class UnattendedService extends GenericService<Unattended> {

    public UnattendedService() {
        super(Unattended.class);
    }

    public List<Unattended> findUnattended(Doctor doc) {
        try {
            String sql = "SELECT u FROM Unattended u JOIN u.doctor d WHERE d.id = :id";
            Query query = getEntityManager().createQuery(sql);
            query.setParameter("id", doc.getId());
            return (List<Unattended>) query.getResultList();
        } catch (Exception e) {
            return new ArrayList<Unattended>();
        }
    }
}
